﻿<Application x:Class="ButtonTemplate.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:local="clr-namespace:ButtonTemplate"
             StartupUri="MainWindow.xaml">
    <Application.Resources>
        <Style x:Key ="RoundButtonStyle" TargetType ="Button">
            <Setter Property ="Foreground" Value ="Black"/>
            <Setter Property ="FontSize" Value ="14"/>
            <Setter Property ="FontWeight" Value ="Bold"/>
            <Setter Property="Width" Value="100"/>
            <Setter Property="Height" Value="100"/>
            <!-- Here is the template! -->
            <Setter Property ="Template">
                <Setter.Value>
                    <ControlTemplate TargetType ="Button">
                        <Grid x:Name="controlLayout">
                            <Ellipse x:Name="buttonSurface" Fill="{TemplateBinding Background}"/>
                            <Label x:Name="buttonCaption" Content ="{TemplateBinding Content}"
                                   HorizontalAlignment="Center" VerticalAlignment="Center" />
                        </Grid>
                        <ControlTemplate.Triggers>
                            <Trigger Property = "IsMouseOver" Value = "True">
                                <Setter TargetName = "buttonSurface" Property = "Fill" Value = "Blue"/>
                                <Setter TargetName = "buttonCaption" Property = "Foreground" Value = "Yellow"/>
                            </Trigger>
                            <Trigger Property = "IsPressed" Value="True">
                                <Setter TargetName="controlLayout"
                                        Property="RenderTransformOrigin" Value="0.5,0.5"/>
                                <Setter TargetName="controlLayout" Property="RenderTransform">
                                    <Setter.Value>
                                        <ScaleTransform ScaleX="0.8" ScaleY="0.8"/>
                                    </Setter.Value>
                                </Setter>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <ControlTemplate x:Key="RoundButtonTemplate" TargetType="Button" >
            <Grid x:Name="controlLayout">
                <Ellipse x:Name="buttonSurface" Fill="{TemplateBinding Background}" />
                <Label x:Name="buttonCaption" Content="{TemplateBinding Content}" FontSize="20" FontWeight="Bold"
                       HorizontalAlignment="Center" VerticalAlignment="Center" />
            </Grid>
            <ControlTemplate.Triggers>
                <Trigger Property = "IsMouseOver" Value = "True">
                    <Setter TargetName = "buttonSurface" Property = "Fill" Value = "Blue"/>
                    <Setter TargetName = "buttonCaption" Property = "Foreground" Value = "Yellow"/>
                </Trigger>
                <Trigger Property = "IsPressed" Value="True">
                    <Setter TargetName="controlLayout" Property="RenderTransformOrigin" Value="0.5,0.5"/>
                    <Setter TargetName="controlLayout" Property="RenderTransform">
                        <Setter.Value>
                            <ScaleTransform ScaleX="0.8" ScaleY="0.8"/>
                        </Setter.Value>
                    </Setter>
                </Trigger>
            </ControlTemplate.Triggers>
        </ControlTemplate>
    </Application.Resources>
</Application>
